﻿@using SelfManagement.Web.Models.ViewModels.DailyModels
@model DailyPagedListModel
<!-- BEGIN SEARCH FORM PORTLET -->
<!-- END SEARCH FORM PORTLET -->
<!-- BEGIN TABLE PORTLET -->
<div class="portlet box light-grey">
    <div class="portlet-title">
        <div class="caption">
            <i class="fa fa-reorder"></i>@ViewBag.Title
        </div>
        <div class="actions">
            <a href="@Url.Action("CreateOrEdit")" name="options" class="toggle btn btn-success btn-sm active"><i class="fa fa-plus"></i>新建计划</a>
        </div>
    </div>
    <div class="portlet-body">
        <div class="table-toolbar">

            <form role="form">
                <div class="form-body">
                    <div class="form-group col-lg-3 col-md-4 col-sm-6">
                        <label for="@nameof(Model.Keyword)">
                            关键字：
                        </label>
                        @Html.TextBoxFor(m => m.Keyword, new { @class = "form-control" })
                    </div>
                    <div class="form-group  col-lg-3 col-md-4 col-sm-6">
                        <label for="@nameof(Model.Status)">
                            @Html.DisplayNameFor(m => m.Status)：
                        </label>
                        @Html.DropDownListFor(m => m.Status, Model.TaskStatusSelectItems, new { @class = "form-control select2" })
                    </div>
                    <div class="form-group col-lg-3 col-md-4 col-sm-6">
                        <label for="@nameof(Model.Date)">
                            @Html.DisplayNameFor(m => m.Date)
                        </label>
                        <div class="input-group date form_datetime month">
                            <input type="text" name="@nameof(Model.Date)" value="@(Model.Date?.ToString("yyyy-MM-dd"))" class="form-control" readonly />
                            <span class="input-group-btn">
                                <button class="btn btn-success date-reset" type="button"><i class="fa fa-times"></i></button>
                                <button class="btn btn-success date-set" type="button"><i class="fa fa-calendar"></i></button>
                            </span>
                        </div>
                    </div>
                    <div class="form-group col-lg-3 col-md-4 col-sm-6">
                        <label>
                            &nbsp;
                        </label>
                        <div class="input-group">
                            <span class="input-group-btn">
                                <button class="btn btn-primary margin-right-10" type="submit"><i class="fa fa-search"></i>搜索</button>
                                <button type="button" class="btn btn-default js-search-form-reset-button margin-right-10">重置</button>
                            </span>
                        </div>
                    </div>
                </div>
                <div class="clearfix">
                </div>

            </form>
        </div>
        <div class="dataTables_wrapper form-inline">
            <div class="table-scrollable">
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                        <tr>
                            <th>
                                操作
                            </th>
                            <th>
                                日期
                            </th>
                            <th>
                                任务名称
                            </th>
                            <th>
                                任务数量
                            </th>
                            <th>
                                (总结)表现/进步/快乐的事情/反思
                            </th>
                            <th>
                                完成情况
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.PagedList)
                        {
                            <tr>
                                <td>
                                    <a href="@Url.Action("CreateOrEdit","Daily",new { id = item.Id })" class="btn btn-info btn-xs"><i class="fa fa-edit"></i>编辑</a>
                                    <a data-confirm-text="确定要删除吗？" data-confirm-button="确定" data-cancel-button="取消"
                                       data-confirmed-url="@Url.Action("Delete", "Daily", new { id = item.Id })"
                                       class="btn btn-danger btn-xs js-table-ajax-confirm-button">
                                        <i class="fa fa-trash-o"></i>删除
                                    </a>
                                </td>
                                <td>
                                    @item.Date.ToShortDateString()
                                </td>
                                <td>
                                    @Html.DisplayFor(m => item.TaskName)
                                </td>
                                <td>
                                    @(item.Tasks.Count())
                                </td>
                                <td>
                                    @(item.Performance.RemoveTags().SubstringWithDots(30))
                                </td>
                                <td>
                                    @{ 
                                        var statusClass = item.Status == TaskStatus.Completed ? "success" : (item.Status == TaskStatus.Deffered ? "danger" : "warning");
                                    }
                                    <a class="btn btn-@(statusClass) btn-xs"><i class="fa fa-edit"></i>@(item.Status.EnumDescription())</a>
                                </td>
                            </tr>

                        }
                    </tbody>
                </table>
            </div>
            @Html.Partial("_Pagination", Model.PagedList, Model.QueryParameter)
        </div>
    </div>
</div>
<!-- BEGIN TABLE PORTLET -->
